<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$data[':uniacid']=$_W['uniacid'];
$uid = $_GPC['uid'];
$where="uid =".$_GPC['uid'];
$page = max(1, intval($_GPC['page']));
$size = intval($_GPC['psize']) ? intval($_GPC['psize']) : 10;
$sql = "SELECT * FROM ims_yzzc_sun_user_drive where ".$where." ORDER BY id DESC LIMIT ".(($page-1) * $size).','.$size;
$list = pdo_fetchall($sql);
foreach ($list as $key =>$value){
    $list[$key]['time']=date('Y-m-d H:i:s',$value['time']);
}
$total=pdo_fetchcolumn("select count(*) from ims_yzzc_sun_user_drive where ".$where);
$pager = pagination($total, $page, $size);

if($_GPC['op']=='delete'){
    $info=pdo_get('yzzc_sun_user_drive',array('id'=>$_GPC['id']));
    // if($info['status']==1){
        $res=pdo_delete('yzzc_sun_user_drive',array('id'=>$_GPC['id'],'uniacid'=>$_W['uniacid']));
        if($info['sfimg']){
        	unlink('../attachment/'.$info['sfimg']);
        }
        if($info['jsimg']){
        	unlink('../attachment/'.$info['jsimg']);
        }
        if($info['sfimgfan']){
        	unlink('../attachment/'.$info['sfimgfan']);
        }
        if($info['jsimgfan']){
        	unlink('../attachment/'.$info['jsimgfan']);
        }
        if($info['zpimg']){
        	unlink('../attachment/'.$info['zpimg']);
        }
        if($res){
            message('删除成功！', $this->createWebUrl('user_drive',array('uid'=>$_GPC['uid'])), 'success');
        }else{
            message('删除失败！','','error');
        }
    // }else{
        // message('空闲车辆才能删除，当前车辆无法删除！','','error');
    // }

}

include $this->template('web/user_drive');